package com.lanou.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.entity.MyNotice;
import com.lanou.mapper.MyNoticeMapper;
import com.lanou.service.MyNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName MyNoticeServiceImpl
 * @Description TODO
 * @Author lizhenjiang
 * @Date 2025年08月15日 16:44
 * @Version 1.0
 */
@Service
public class MyNoticeServiceImpl implements MyNoticeService {
    @Autowired
    private MyNoticeMapper myNoticeMapper;


    @Override
    public int addMyNotice(MyNotice myNotice) {
        return myNoticeMapper.addMyNotice(myNotice);
    }

    @Override
    public PageInfo<MyNotice> getMyNotices(Integer userId,Integer pageNum, Integer pageSize) {
        if(pageNum==null&&pageSize==null){
            PageInfo<MyNotice> pageInfo= new PageInfo<>(myNoticeMapper.getMyNotice(userId));
            return pageInfo;
        }
        PageHelper.startPage(pageNum, pageSize);
        List<MyNotice> myNotices=myNoticeMapper.getMyNotice(userId);
        PageInfo<MyNotice> pageInfo=new PageInfo<>(myNotices);
        return pageInfo;
    }
}
